package com.example.dell.test1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by klren on 2016/6/1.
 */
public class HomeActivity extends Activity {
    Button game,map,weather,app;

    //获取年月日
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 ");
    Date curDate = new Date(System.currentTimeMillis());//获取当前时间
    String str = formatter.format(curDate);

    //获取小时分钟
    SimpleDateFormat formatter1 = new SimpleDateFormat (" HH:mm ");
    Date curDate1 = new Date(System.currentTimeMillis());//获取当前时间
    String str1 = formatter1.format(curDate1);


    //将要在listview中显示的数据放到data数组里
    private String[] data = {str,str1,"檀甜甜","汪浡湶","孙宇","任志伟"};

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        game = (Button)findViewById(R.id.gamebtn);
        map = (Button)findViewById(R.id.mapbtn);
        weather = (Button)findViewById(R.id.weatherbtn);
        app = (Button)findViewById(R.id.appbtn);

        /**
         * 2048游戏按钮点击
         */
        game.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.this,GameActivity.class);
                startActivity(intent);
            }
        });

        /**
         * 地图按钮点击
         */
        map.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.this,MapActivity.class);
                startActivity(intent);
            }
        });

        /**
         * 天气按钮点击
         */
        weather.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.this,WeatherActivity.class);
                startActivity(intent);
            }
        });

        /**
         * 轻应用按钮点击
         */
        app.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeActivity.this,AppActivity.class);
                startActivity(intent);
            }
        });

        //listview定义
        ArrayAdapter<String> adapter  = new ArrayAdapter<>(
                HomeActivity.this, android.R.layout.simple_list_item_1, data);
        ListView listView = (ListView)findViewById(R.id.listView);
        listView.setAdapter(adapter);

    }
}
